package yja.gzw.app.adapter

import android.content.Context
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.CircleCrop
import com.bumptech.glide.request.RequestOptions
import yja.gzw.app.R
import yja.gzw.app.model.bean.OrderData
import yja.gzw.app.model.bean.OrderInfoBean

class ChujiaAdapter (private val context: Context, private val list: List<OrderInfoBean>): RecyclerView.Adapter<RecyclerView.ViewHolder>(){
    private var view: View?=null

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
        view= LayoutInflater.from(parent.context).inflate(R.layout.item_view_chujia,parent,false)

        return ViewHodeView(view!!)
    }

    override fun getItemCount(): Int {
        return list.size
    }

    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        if(holder is ViewHodeView){
            val requestOptions = RequestOptions.bitmapTransform(CircleCrop())
            Glide.with(context).load("http://117ai.32.hzgqapp.com/"+list[position].avatar)
                .apply(requestOptions)
                .into(holder.touxiang)

            holder.names.text=list[position].username

            holder.chujianqian.text="价格￥"+list[position].price

        }



    }


    inner class ViewHodeView(itemView: View):RecyclerView.ViewHolder(itemView){
        val touxiang: ImageView =itemView.findViewById(R.id.touxiang)
        val names: TextView =itemView.findViewById(R.id.name)
        val chujianqian: TextView =itemView.findViewById(R.id.chujianqian)
    }

}